package com.zhx.threadcoreknowledge.synchromized;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-10-01 21:00
 * 用途         ： 消失的请求数
 */
public class DisappeaRequest1 implements Runnable{
    static DisappeaRequest1 disappeaRequest1 = new DisappeaRequest1();

    static int i = 0;

    @Override
    public void run() {
        for (int j = 0; j < 100000; j++) {
            i++;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(disappeaRequest1);
        Thread thread2 = new Thread(disappeaRequest1);

        thread1.start();
        thread2.start();
        /**
         * 把线程变成同步
         */
        thread1.join();
        thread2.join();

        System.out.println(i);
    }
}
